<template>
    <div>
        <label class="sr-only" v-if="props.label">{{ props.label }}</label>
        <slot />
    </div>
</template>
<script setup>
import { inject, onMounted } from "vue";
const props = defineProps({
  label: String,
  prop: String,
});

let FormContext = inject("FormContext");

const validate = () => {
  if (!FormContext.model[props.prop]) {
    return false;
  }
  return true;
};

onMounted(() => {
  FormContext.register({
    name: props.prop,
    validate: validate,
  });
});

</script>